<!DOCTYPE html>
{% load static %}
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章归档页</title>
    <style>
        /* CSS样式可以根据需要自行添加 */
        /* 页面居中显示 */
        body {
            background-image: url("{% static 'img/myimg.jpg' %}");
            background-size: cover;
            background-repeat: no-repeat;
            background-attachment: fixed; /* 保持背景图固定不随滚动而移动 */
            background-position: center;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
        }

        /* 整体容器 */
        .container {
            width: 80%; /* 调整宽度 */
            background-color: rgba(255, 255, 255, 0.6); /* 设置背景色并调整透明度 */
            backdrop-filter: blur(10px); /* 添加毛玻璃效果 */
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            margin-top: 50px; /* Add some space from top */
        }

        /* 导航栏 */
        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #999;
            color: white;
            padding: 10px 20px;
            border-radius: 20px;
        }
        .navbar button {
            color: white;
            background-color: transparent;
            border: none;
            cursor: pointer;
        }
        .search {
            width: 200px; /* 调整搜索框宽度 */
        }

        /* 文章列表 */
        h1 {
            text-align: center;
        }
        ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        li {
            margin-bottom: 10px;
            background-color: white;
            padding: 10px;
            border-radius: 4px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
        }
        a {
            text-decoration: none;
            color: black;
        }
        .pagination {
            text-align: center;
            margin-top: 20px;
        }

        /* 用户文章 */
        .user-articles {
            margin-top: 20px;
        }
        .article {
            {#background-color: white;#}
            margin-bottom: 10px;
            background-color: rgba(255, 255, 255, 0.6);
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        {#限制超出长度的摘要#}
        .article p {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 导航栏 -->
        <div class="navbar">
            <button><a href="/">首页</a></button>
            <button><a href="/blog/edit/">写博客</a></button>
            <!-- Add other navigation buttons as needed -->

{#            <!-- Example of Search Form -->#}
{#            <form action="{% url 'search_results' usrname=requested_user.username %}" method="GET">#}
{#                <input type="text" class="search" placeholder="Search for something!!!" name="query">#}
{#                <button type="submit">搜索</button>#}
{#            </form>#}

            <button><a href="/user/centre/{{ current_user }}">我的主页</a></button>
            {% if published %}
            <button><a href="/blog/drafts/{{ current_user }}/">草稿箱</a></button>
            {% else %}
            <button><a href="/blog/archieve/{{ current_user }}/">我的博客</a></button>
            {% endif %}
            <button><a href="/user/logout/">退出</a></button>
            <!-- Add other navigation buttons as needed -->
        </div>

        <!-- 主体内容 -->
        {% if published %}
            <h1>文章归档</h1>
        {% else %}
            <h1>草稿箱</h1>
        {% endif %}
        <div class="user-articles">
            {% for article in article_list %}
            
            <div class="article">
                <a href="/blog/article/{{ article.author }}/{{ article.aid }}" class="article-link">
                    <h2>{{ article.title }}</h2>
                    <h6>更新时间：{{ article.updatedAt }}</h6>
                    <p>{{ article.abstract }}</p>
                </a>
                <button onclick="confirmDelete('{{ article.aid }}')">删除</button>
            </div>
                {% empty %}
            <li>吃饱了撑？写篇博客罢！！！</li>
            {% endfor %}

        </div>

        <!-- Pagination -->
        <div class="pagination">
            <span class="step-links">
                {% if page_obj.has_previous %}
                    <a href="?page=1">&laquo; first&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                    <a href="?page={{ page_obj.previous_page_number }}">previous&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                {% endif %}

                <span class="current">
                    Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </span>

                {% if page_obj.has_next %}
                    <a href="?page={{ page_obj.next_page_number }}">next&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                    <a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a>
                {% endif %}
            </span>
        </div>
    </div>
</body>
<script>
    function confirmDelete(aid) {
        if (confirm("当真要删除这篇博客吗？")) {
            window.location.href = "/blog/delete/" + aid + "/";
        }
    }
</script>
</html>
